<?php
if( !defined('__ROOT__') ) die('Access denied');
class View{
	public $ext;
	public $path;

	public function __construct(){
		$this->ext = 'html';
		$this->path = __VIEW__;
	}

	public function display($tpl, $data){
		$file = $this->path.$tpl.'.'.$this->ext;
		if( empty($tpl) || !file_exists($file) ){
			$this->error('Template file: '.$file.' not found');
		} 
		if( is_array($data) ) extract($data);
		include( $file );
	}

	public function error($msg){
		echo $msg;
		exit;
	}
}
